# ============================================================================
# WEB2PY SNIPPETS
# web2py.snippets is based on web2py version 1.76.3
#
# @see http://github.com/lvidarte/web2py-snippets
# @author Leonardo Vidarte <lvidarte[AT]gmail.com>
# ============================================================================
#
# For autoload set in python files (web2py):
# # vim:set filetype=python.web2py:
#
# For autoload set in html files (templates web2py):
# {{# vim:set filetype=html.web2py: }}

# ============================================================================
# COMPLETE API
# ============================================================================
#
# <url:#Container Objects>
# request, response, session, cache
#
# <url:#Navigation Functions and Objects>
# redirect, HTTP
#
# <url:#Thread safe app-level module import>
# local_import
#
# <url:#Internationalization>
# T
#
# <url:#Views Helpers>
# XML, URL, BEAUTIFY
#
# <url:#HTTP Building Objects>
# A, B, BODY, BR, CENTER, CODE, DIV, EM, EMBED, FIELDSET, FORM,
# H1, H3, H3, H4, H5, H6, HEAD, HR, HTML, IFRAME, IMG, INPUT,
# LABEL, LI, LINK, OL, UL, MENU, META, OBJECT, ON, OPTION, P, PRE,
# SCRIPT, SELECT, SPAN, STYLE, TABLE, TD, TAG, TBODY,
# TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT
#
# <url:#Validator Objects>
# IS_ALPHANUMERIC, IS_DATE, IS_DATETIME,
# IS_DATE_IN_RANGE, IS_DATETIME_IN_RANGE, IS_DECIMAL_IN_RANGE, IS_EMAIL,
# IS_EXPR, IS_FLOAT_IN_RANGE, IS_IMAGE, IS_INT_IN_RANGE, IS_IN_SET,
# IS_IPV4, IS_LENGTH, IS_LOWER, IS_MATCH, IS_EMPTY_OR, IS_NOT_EMPTY,
# IS_TIME, IS_URL, IS_UPLOAD_FILENAME, IS_LIST_OF, IS_UPPER,
# IS_SLUG, IS_STRONG, CLEANUP, CRYPT, IS_IN_DB, IS_NOT_IN_DB
#
# <url:#Database API>
# DAL, Field
#
# <url:#Database to HTML>
# SQLFORM, SQLTABLE
#
# Plus: <url:#Templates>

# ============================================================================
# Container objects
# ============================================================================
snippet request_
request.${1:vars|args|cookies|get_vars|post_vars|client|application|controller|function|folder|extension|now|env}
snippet response_
response.${1:status|headers|view|cookies|flash|title|menu}
snippet session_
session.${1:varname}
snippet cache_
cache.${1:ram|disk}
# ============================================================================
# Navigation Functions and Objects
# ============================================================================
#redirect, HTTP
snippet http_
HTTP(${1:status}, body='${2:}', ${3:**headers}){$4}
snippet redirect_
redirect(${1:location}, how=${2:303})${3}
# ============================================================================
# Thread safe app-level module import
# ============================================================================
snippet local_import_
local_import(${1:name}, reload=${2:False}, app=${3:request.application})${4}
# ============================================================================
# Internationalization
# ============================================================================
snippet t_
T('${1:message}')${2}
snippet t__
T('${1:message}', symbols={})${2}
# ============================================================================
# Views Helpers
# ============================================================================
## URL
snippet url_
URL(r=request, f='${1:index}'${2})${3}
snippet url__
URL(a=${1:None}, c=${2:None}, f=${3:None}, r=${4:None}, args=[], vars={}, anchor='', extension=None)${5}
snippet helpers_ URL
URL(a=${1:None}, c=${2:None}, f=${3:None}, r=${4:None}, args=[], vars={}, anchor='', extension=None)${5}
## XML
snippet xml_
XML(${1:text}${2})${3}
snippet xml__
XML(${1:text}, sanitize=${2:False}, permitted_tags=['a','b','blockquote','br/','i','li','ol','ul','p','cite','code','pre','img/',], allowed_attributes={'a': ['href', 'title'], 'img': ['src': 'alt'], 'blockquote': ['type']})${3}
snippet helpers_ XML
XML(${1:text}, sanitize=${2:False}, permitted_tags=['a','b','blockquote','br/','i','li','ol','ul','p','cite','code','pre','img/',], allowed_attributes={'a': ['href', 'title'], 'img': ['src': 'alt'], 'blockquote': ['type']})${3}
## BEAUTIFY
snippet beautify_
BEAUTIFY(${1:*components}${2})${3}
snippet beautify__
BEAUTIFY(${1:*components}, ${2:**attributes})${3}
snippet helpers_ BEAUTIFY
BEAUTIFY(${1:*components}, ${2:**attributes})${3}
# ============================================================================
# HTTP Building Objects
# ============================================================================
## DIV
snippet div_
DIV(${1:*components})${2}
snippet div__
DIV(${1:*components}, ${2:**attributes})${3}
snippet helpers_ DIV
DIV(${1:*components}, ${2:**attributes})${3}
## TAG
snippet tag_
TAG.${1:tag}(${2:*components})${3}
snippet tag__
TAG.${1:tag}(${2:*components}, ${3:**attributes})${4}
snippet helpers_ TAG
TAG.${1:tag}(${2:*components}, ${3:**attributes})${4}
## HTML
snippet html_
HTML(${1:*components})${2}
snippet html__
HTML(${1:*components}, ${2:**attributes}, doctype='${3:strict|transitional|frameset|html5}', lang='${4:en}')${5}
snippet helpers_ HTML
HTML(${1:*components}, ${2:**attributes}, doctype='${3:strict|transitional|frameset|html5}', lang='${4:en}')${5}
## XHTML
snippet xhtml_
XHTML(${1:*components}, ${2:**attributes})${3}
snippet xhtml__
XHTML(${1:*components}, ${2:**attributes}, doctype='${3:strict|transitional|frameset}', lang='${4:en}', xmlns='${5:http://www.w3.org/1999/xhtml}')${6}
snippet helpers_ XHTML
XHTML(${1:*components}, ${2:**attributes}, doctype='${3:strict|transitional|frameset}', lang='${4:en}', xmlns='${5:http://www.w3.org/1999/xhtml}')${6}
## HEAD
snippet head_
HEAD(${1:*components})${2}
snippet head__
HEAD(${1:*components}, ${2:**attributes})${3}
snippet helpers_ HEAD
HEAD(${1:*components}, ${2:**attributes})${3}
## TITLE
snippet title_
TITLE(${1:*components})${2}
snippet title__
TITLE(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TITLE
TITLE(${1:*components}, ${2:**attributes})${3}
## META
snippet meta_
META(${1:*components})${2}
snippet meta__
META(${1:*components}, ${2:**attributes})${3}
snippet helpers_ META
META(${1:*components}, ${2:**attributes})${3}
## LINK
snippet link_
LINK(${1:*components})${2}
snippet link__
LINK(${1:*components}, ${2:**attributes})${3}
snippet helpers_ LINK
LINK(${1:*components}, ${2:**attributes})${3}
## SCRIPT
snippet script_
SCRIPT(${1:*components})${2}
snippet script__
SCRIPT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ SCRIPT
SCRIPT(${1:*components}, ${2:**attributes})${3}
## STYLE
snippet style_
STYLE(${1:*components})${2}
snippet style__
STYLE(${1:*components}, ${2:**attributes})${3}
snippet helpers_ STYLE
STYLE(${1:*components}, ${2:**attributes})${3}
## IMG
snippet img_
IMG(${1:*components})${2}
snippet img__
IMG(${1:*components}, ${2:**attributes})${3}
snippet helpers_ IMG
IMG(${1:*components}, ${2:**attributes})${3}
## SPAN
snippet span_
SPAN(${1:*components})${2}
snippet span__
SPAN(${1:*components}, ${2:**attributes})${3}
snippet helpers_ SPAN
SPAN(${1:*components}, ${2:**attributes})${3}
## BODY
snippet body_
BODY(${1:*components})${2}
snippet body__
BODY(${1:*components}, ${2:**attributes})${3}
snippet helpers_ BODY
BODY(${1:*components}, ${2:**attributes})${3}
## H1
snippet h1_
H1(${1:*components})${2}
snippet h1__
H1(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H1
H1(${1:*components}, ${2:**attributes})${3}
## H2
snippet h2_
H2(${1:*components})${2}
snippet h2__
H2(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H2
H2(${1:*components}, ${2:**attributes})${3}
## H3
snippet h3_
H3(${1:*components})${2}
snippet h3__
H3(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H3
H3(${1:*components}, ${2:**attributes})${3}
## H4
snippet h4_
H4(${1:*components})${2}
snippet h4__
H4(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H4
H4(${1:*components}, ${2:**attributes})${3}
## H5
snippet h5_
H5(${1:*components})${2}
snippet h5__
H5(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H5
H5(${1:*components}, ${2:**attributes})${3}
## H6
snippet h6_
H6(${1:*components})${2}
snippet h6__
H6(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H6
H6(${1:*components}, ${2:**attributes})${3}
## P
snippet p_
P(${1:*components})${2}
snippet p__
P(${1:*components}, ${2:**attributes})${3}
snippet helpers_ P
P(${1:*components}, ${2:**attributes})${3}
## B
snippet b_
B(${1:*components})${2}
snippet b__
B(${1:*components}, ${2:**attributes})${3}
snippet helpers_ B
B(${1:*components}, ${2:**attributes})${3}
## BR
snippet br_
BR(${1:*components})${2}
snippet br__
BR(${1:*components}, ${2:**attributes})${3}
snippet helpers_ BR
BR(${1:*components}, ${2:**attributes})${3}
## HR
snippet hr_
HR(${1:*components})${2}
snippet hr__
HR(${1:*components}, ${2:**attributes})${3}
snippet helpers_ HR
HR(${1:*components}, ${2:**attributes})${3}
## A
snippet a_
A(${1:*components})${2}
snippet a__
A(${1:*components}, ${2:**attributes})${3}
snippet helpers_ A
A(${1:*components}, ${2:**attributes})${3}
## EM
snippet em_
EM(${1:*components})${2}
snippet em__
EM(${1:*components}, ${2:**attributes})${3}
snippet helpers_ EM
EM(${1:*components}, ${2:**attributes})${3}
## EMBED
snippet embed_
EMBED(${1:*components})${2}
snippet embed__
EMBED(${1:*components}, ${2:**attributes})${3}
snippet helpers_ EMBED
EMBED(${1:*components}, ${2:**attributes})${3}
## TT
snippet tt_
TT(${1:*components})${2}
snippet tt__
TT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TT
TT(${1:*components}, ${2:**attributes})${3}
## PRE
snippet pre_
PRE(${1:*components})${2}
snippet pre__
PRE(${1:*components}, ${2:**attributes})${3}
snippet helpers_ PRE
PRE(${1:*components}, ${2:**attributes})${3}
## CENTER
snippet center_
CENTER(${1:*components})${2}
snippet center__
CENTER(${1:*components}, ${2:**attributes})${3}
snippet helpers_ CENTER
CENTER(${1:*components}, ${2:**attributes})${3}
## CODE
snippet code_
CODE(${1:*components}, language='${2:python}').xml()${3}
snippet code__
CODE(${1:*components}, language='${2:python}', link=None, counter=1, styles={}).xml()${3}
snippet helpers_ CODE
CODE(${1:*components}, language='${2:python}', link=None, counter=1, styles={}).xml()${3}
## LABEL
snippet label_
LABEL(${1:*components})${2}
snippet label__
LABEL(${1:*components}, ${2:**attributes})${3}
snippet helpers_ LABEL
LABEL(${1:*components}, ${2:**attributes})${3}
## LI
snippet li_
LI(${1:*components})${2}
snippet li__
LI(${1:*components}, ${2:**attributes})${3}
snippet helpers_ LI
LI(${1:*components}, ${2:**attributes})${3}
## UL
snippet ul_
UL(${1:*components})${2}
snippet ul__
UL(${1:*components}, ${2:**attributes})${3}
snippet helpers_ UL
UL(${1:*components}, ${2:**attributes})${3}
## OL
snippet ol_
OL(${1:*components})${2}
snippet ol__
OL(${1:*components}, ${2:**attributes})${3}
snippet helpers_ OL
OL(${1:*components}, ${2:**attributes})${3}
## TD
snippet td_
TD(${1:*components})${2}
snippet td__
TD(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TD
TD(${1:*components}, ${2:**attributes})${3}
## TH
snippet th_
TH(${1:*components})${2}
snippet th__
TH(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TH
TH(${1:*components}, ${2:**attributes})${3}
## TR
snippet tr_
TR(${1:*components})${2}
snippet tr__
TR(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TR
TR(${1:*components}, ${2:**attributes})${3}
## THEAD
snippet thead_
THEAD(${1:*components})${2}
snippet thead__
THEAD(${1:*components}, ${2:**attributes})${3}
snippet helpers_ THEAD
THEAD(${1:*components}, ${2:**attributes})${3}
## TBODY
snippet tbody_
TBODY(${1:*components})${2}
snippet tbody__
TBODY(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TBODY
TBODY(${1:*components}, ${2:**attributes})${3}
## TFOOT
snippet tfoot_
TFOOT(${1:*components})${2}
snippet tfoot__
TFOOT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TFOOT
TFOOT(${1:*components}, ${2:**attributes})${3}
## TABLE
snippet table_
TABLE(${1:*components})${2}
snippet table__
TABLE(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TABLE
TABLE(${1:*components}, ${2:**attributes})${3}
## I
snippet i_
I(${1:*components})${2}
snippet i__
I(${1:*components}, ${2:**attributes})${3}
snippet helpers_ I
I(${1:*components}, ${2:**attributes})${3}
## IFRAME
snippet iframe_
IFRAME(${1:*components})${2}
snippet iframe__
IFRAME(${1:*components}, ${2:**attributes})${3}
snippet helpers_ IFRAME
IFRAME(${1:*components}, ${2:**attributes})${3}
## INPUT
snippet input_
INPUT(${1:*components})${2}
snippet input__
INPUT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ INPUT
INPUT(${1:*components}, ${2:**attributes})${3}
## TEXTAREA
snippet textarea_
TEXTAREA(${1:*components})${2}
snippet textarea__
TEXTAREA(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TEXTAREA
TEXTAREA(${1:*components}, ${2:**attributes})${3}
## OPTION
snippet option_
OPTION(${1:*components})${2}
snippet option__
OPTION(${1:*components}, ${2:**attributes})${3}
snippet helpers_ OPTION
OPTION(${1:*components}, ${2:**attributes})${3}
## OBJECT
snippet object_
OBJECT(${1:*components})${2}
snippet object__
OBJECT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ OBJECT
OBJECT(${1:*components}, ${2:**attributes})${3}
## SELECT
snippet select_
SELECT(${1:*components})${2}
snippet select__
SELECT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ SELECT
SELECT(${1:*components}, ${2:**attributes})${3}
## FIELDSET
snippet fieldset_
FIELDSET(${1:*components})${2}
snippet fieldset__
FIELDSET(${1:*components}, ${2:**attributes})${3}
snippet helpers_ FIELDSET
FIELDSET(${1:*components}, ${2:**attributes})${3}
## LEGEND
snippet legend_
LEGEND(${1:*components})${2}
snippet legend__
LEGEND(${1:*components}, ${2:**attributes})${3}
snippet helpers_ LEGEND
LEGEND(${1:*components}, ${2:**attributes})${3}
## FORM
snippet form_
FORM(${1:*components})${2}
snippet form__
FORM(${1:*components}, ${2:**attributes})${3}
snippet helpers_ FORM
FORM(${1:*components}, ${2:**attributes})${3}
## MENU
snippet menu_
MENU(${1:*components})${2}
snippet menu__
MENU(${1:*components}, ${2:**attributes})${3}
snippet helpers_ MENU
MENU(${1:*components}, ${2:**attributes})${3}
# ============================================================================
# Validator Objects
# ============================================================================
## IS_ALPHANUMERIC
snippet is_alphanumeric_
IS_ALPHANUMERIC(${1})${2}
snippet is_alphanumeric__
IS_ALPHANUMERIC(error_message='${1:enter only letters, numbers, and underscore}')${2}
snippet validators_ IS_ALPHANUMERIC
IS_ALPHANUMERIC(error_message='${1:enter only letters, numbers, and underscore}')${2}
## IS_DATE
snippet is_date_
IS_DATE(${1})${2}
snippet is_date__
IS_DATE(format='${1:%Y-%m-%d}', error_message='${2:enter date as %(format)s}')${3}
snippet validators_ IS_DATE
IS_DATE(format='${1:%Y-%m-%d}', error_message='${2:enter date as %(format)s}')${3}
## IS_DATETIME
snippet is_datetime_
IS_DATETIME(${1})${2}
snippet is_datetime__
IS_DATETIME(format='${1:%Y-%m-%d %H:%M:%S}', error_message='${2:enter date and time as %(format)s}')${3}
snippet validators_ IS_DATETIME
IS_DATETIME(format='${1:%Y-%m-%d %H:%M:%S}', error_message='${2:enter date and time as %(format)s}')${3}
## IS_DATE_IN_RANGE
snippet is_date_in_range_
IS_DATE_IN_RANGE(minimun=${1:None}, maximun=${2:None}${3})${4}
snippet is_date_in_range__
IS_DATE_IN_RANGE(minimum=${1:None}, maximum=${2:None}, format='${3:%Y-%m-%d}', error_message=${4:None})${5}
snippet validators_ IS_DATE_IN_RANGE
IS_DATE_IN_RANGE(minimum=${1:None}, maximum=${2:None}, format='${3:%Y-%m-%d}', error_message=${4:None})${5}
## IS_DATETIME_IN_RANGE
snippet is_datetime_in_range_
IS_DATETIME_IN_RANGE(minimum=${1:None}, maximum=${2:None}${3})${4}
snippet is_datetime_in_range__
IS_DATETIME_IN_RANGE(minimum=${1:None}, maximum=${2:None}, format='${3:%Y-%m-%d %H:%M:%S}', error_message=${4:None})${5}
snippet validators_ IS_DATETIME_IN_RANGE
IS_DATETIME_IN_RANGE(minimum=${1:None}, maximum=${2:None}, format='${3:%Y-%m-%d %H:%M:%S}', error_message=${4:None})${5}
## IS_DECIMAL_IN_RANGE
snippet is_decimal_in_range_
IS_DECIMAL_IN_RANGE(${1:minimum}, ${2:maximum}${3})${4}
snippet is_decimal_in_range__
IS_DECIMAL_IN_RANGE(${1:minimun}, ${2:maximun}, error_message=${3:None})${4}
snippet validators_ IS_DECIMAL_IN_RANGE
IS_DECIMAL_IN_RANGE(${1:minimun}, ${2:maximun}, error_message=${3:None})${4}
## IS_EMAIL
snippet is_email_
IS_EMAIL(${1})${2}
snippet is_email__
IS_EMAIL(banned=${1:None}, forced=${2:None}, error_message='${3:enter a valid email address}')${4}
snippet validators_ IS_EMAIL
IS_EMAIL(banned=${1:None}, forced=${2:None}, error_message='${3:enter a valid email address}')${4}
## IS_EXPR
snippet is_expr_
IS_EXPR(${1:expression}${2})${3}
snippet is_expr__
IS_EXPR(${1:expression}, error_message='${2:invalid expression}')${3}
snippet validators_ IS_EXPR
IS_EXPR(${1:expression}, error_message='${2:invalid expression}')${3}
## IS_FLOAT_IN_RANGE
snippet is_float_in_range_
IS_FLOAT_IN_RANGE(${1:minimum}, ${2:maximum}${3})${4}
snippet is_float_in_range__
IS_FLOAT_IN_RANGE(${1:minimum}, ${2:maximum}, error_message=${3:None})${4}
snippet validators_ IS_FLOAT_IN_RANGE
IS_FLOAT_IN_RANGE(${1:minimum}, ${2:maximum}, error_message=${3:None})${4}
## IS_IMAGE
snippet is_image_
IS_IMAGE(${1})${2}
snippet is_image__
IS_IMAGE(extensions=('bmp','gif','jpeg','png'), maxsize=(${1:10000}, ${2:10000}), minsize=(${3:0}, ${4:0}), error_message='${5:invalid image}')${6}
snippet validators_ IS_IMAGE
IS_IMAGE(extensions=('bmp','gif','jpeg','png'), maxsize=(${1:10000}, ${2:10000}), minsize=(${3:0}, ${4:0}), error_message='${5:invalid image}')${6}
## IS_INT_IN_RANGE
snippet is_int_in_range_
IS_INT_IN_RANGE(${1})${2}
snippet is_int_in_range__
IS_INT_IN_RANGE(${1:minimum}, ${2:maximum}, error_message=${3:None})${4}
snippet validators_ IS_INT_IN_RANGE
IS_INT_IN_RANGE(${1:minimum}, ${2:maximum}, error_message=${3:None})${4}
## IS_IN_SET
snippet is_in_set_
IS_IN_SET(${1:theset}${2})${3}
snippet is_in_set__
IS_IN_SET(${1:theset}, labels=${2:None}, error_message='${3:value not allowed}', multiple=${4:False}, zero='${5}', sort=${6:False})${7}
snippet validators_ IS_IN_SET
IS_IN_SET(${1:theset}, labels=${2:None}, error_message='${3:value not allowed}', multiple=${4:False}, zero='${5}', sort=${6:False})${7}
## IS_IN_SUBSET
snippet is_in_subset_
IS_IN_SUBSET(${1:*a}, ${2:**b})${3}
snippet is_in_subset__
IS_IN_SUBSET(${1:*a}, ${2:**b})${3}
snippet validators_ IS_IN_SUBSET
IS_IN_SUBSET(${1:*a}, ${2:**b})${3}
## IS_IPV4
snippet is_ipv4_
IS_IPV4(${1})${2}
snippet is_ipv4__
IS_IPV4(minip='${1:0.0.0.0}', maxip='${2:255.255.255.255}', invert=${3:False}, is_localhost=${4:None}, is_private=${5:None}, is_automatic=${6:None}, error_message='${7:enter a valid IPv4 address}')${8}
snippet validators_ IS_IPV4
IS_IPV4(minip='${1:0.0.0.0}', maxip='${2:255.255.255.255}', invert=${3:False}, is_localhost=${4:None}, is_private=${5:None}, is_automatic=${6:None}, error_message='${7:enter a valid IPv4 address}')${8}
## IS_LENGTH
snippet is_length_
IS_LENGTH(maxsize=${1:255}, minsize=${2:0}${3})${4}
snippet is_length__
IS_LENGTH(maxsize=${1:255}, minsize=${2:0}, error_message='${3:enter from %(min)s to %(max)s characters}')${4}
snippet validators_ IS_LENGTH
IS_LENGTH(maxsize=${1:255}, minsize=${2:0}, error_message='${3:enter from %(min)s to %(max)s characters}')${4}
## IS_LOWER
snippet is_lower_
IS_LOWER()
snippet is_lower__
IS_LOWER()
snippet validators_ IS_LOWER
IS_LOWER()
## IS_MATCH
snippet is_match_
IS_MATCH(${1:expression}${2})${3}
snippet is_match__
IS_MATCH(${1:expression}, error_message='${2:invalid expression}')${3}
snippet validators_ IS_MATCH
IS_MATCH(${1:expression}, error_message='${2:invalid expression}')${3}
## IS_EMPTY_OR
snippet is_empty_or_
IS_EMPTY_OR(${1:other})${2}
snippet is_empty_or__
IS_EMPTY_OR(${1:other}, null=${2:None}, empty_regex=${3:None})${4}
snippet validators_ IS_EMPTY_OR
IS_EMPTY_OR(${1:other}, null=${2:None}, empty_regex=${3:None})${4}
## IS_NOT_EMPTY
snippet is_not_empty_
IS_NOT_EMPTY(${1})${2}
snippet is_not_empty__
IS_NOT_EMPTY(error_message='${1:enter a value}' empty_regex=${2:None})${3}
snippet validators_ IS_NOT_EMPTY
IS_NOT_EMPTY(error_message='${1:enter a value}' empty_regex=${2:None})${3}
## IS_TIME
snippet is_time_
IS_TIME(${1})${2}
snippet is_time__
IS_TIME(error_message='${1:enter time as hh:mm:ss (seconds, am, pm optional)}')${2}
snippet validators_ IS_TIME
IS_TIME(error_message='${1:enter time as hh:mm:ss (seconds, am, pm optional)}')${2}
## IS_URL
snippet is_url_
IS_URL(${1})${2}
snippet is_url__
IS_URL(error_message='${1:enter a valid URL}', mode='${2:http}', allowed_schemes=${3:None}, prepend_scheme='${4:http}')${5}
snippet validators_ IS_URL
IS_URL(error_message='${1:enter a valid URL}', mode='${2:http}', allowed_schemes=${3:None}, prepend_scheme='${4:http}')${5}
## IS_UPLOAD_FILENAME
snippet is_upload_filename_
IS_UPLOAD_FILENAME(${1})${2}
snippet is_upload_filename__
IS_UPLOAD_FILENAME(filename=${1:None}, extension=${2:None}, lastdot=${3:True}, case=${4:1}, error_message='${5:enter valid filename}')${6}
snippet validators_ IS_UPLOAD_FILENAME
IS_UPLOAD_FILENAME(filename=${1:None}, extension=${2:None}, lastdot=${3:True}, case=${4:1}, error_message='${5:enter valid filename}')${6}
## IS_LIST_OF
snippet is_list_of_
IS_LIST_OF(${1:other})${2}
snippet is_list_of__
IS_LIST_OF(${1:other})${2}
snippet validators_ IS_LIST_OF
IS_LIST_OF(${1:other})${2}
## IS_UPPER
snippet is_upper_
IS_UPPER()
snippet is_upper__
IS_UPPER()
snippet validators_ IS_UPPER
IS_UPPER()
## IS_SLUG
snippet is_slug_
IS_SLUG(${1})${2}
snippet is_slug__
IS_SLUG(maxlen=${1:80}, check=${2:False}, error_message='${3:must be slug}')${4}
snippet validators_ IS_SLUG
IS_SLUG(maxlen=${1:80}, check=${2:False}, error_message='${3:must be slug}')${4}
## IS_STRONG
snippet is_strong_
IS_STRONG(${1})${2}
snippet is_strong__
IS_STRONG(min=${1:8}, max=${2:20}, upper=${3:1}, lower=${4:1}, number=${5:1}, special=${6:1}, specials=r'~!@#$%^&*()__-=?<>,.:;{}[]|', invalid='${7: "}', error_message=${8:None})${9}
snippet validators_ IS_STRONG
IS_STRONG(min=${1:8}, max=${2:20}, upper=${3:1}, lower=${4:1}, number=${5:1}, special=${6:1}, specials=r'~!@#$%^&*()__-=?<>,.:;{}[]|', invalid='${7: "}', error_message=${8:None})${9}
## CLEANUP
snippet cleanup_
CLEANUP(${1})${2}
snippet cleanup__
CLEANUP(regex='${1:[^ \n\w]}')${2}
snippet validators_ CLEANUP
CLEANUP(regex='${1:[^ \n\w]}')${2}
## CRYPT
snippet crypt_
CRYPT()
snippet crypt__
CRYPT()
snippet validators_ CRYPT
CRYPT()
## IS_IN_DB
snippet is_in_db_
IS_IN_DB(${1})${2}
snippet is_in_db__
IS_IN_DB(key=${1:None}, digest_alg=${2:None})${3}
snippet validators_ IS_IN_DB
IS_IN_DB(key=${1:None}, digest_alg=${2:None})${3}
## IS_NOT_IN_DB
snippet is_not_in_db_
IS_NOT_IN_DB(${1:dbset}${2})${3}
snippet is_not_in_db__
IS_NOT_IN_DB(${1:dbset}, ${2:field}, error_message='${3:value already in database}', allowed_override=${4:[]})${5}
snippet validators_ IS_NOT_IN_DB
IS_NOT_IN_DB(${1:dbset}, ${2:field}, error_message='${3:value already in database}', allowed_override=${4:[]})${5}
# ============================================================================
# Database API
# ============================================================================
## DAL
snippet dal_
db = DAL('sqlite://${1:dummy}.db')${2}
snippet dal__ sqlite
db = DAL('sqlite://${1:dummy}.db', pool_size=${2:0})${3}
snippet dal__ mysql
db = DAL('mysql://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
snippet dal__ postgres
db = DAL('postgres://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
snippet dal__ oracle
db = DAL('oracle://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
snippet dal__ mssql
db = DAL('mssql://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
snippet dal__ firebird
db = DAL('firebird://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
## TABLES
snippet define_table_
db.define_table('${1:tablename}',${2}
#migrate=False
)
snippet define_table__
db.define_table('${1:tablename}',
Field('${1:fieldname}', '${2:string}'${3}),
Field('${4:fieldname}', '${5:string}'${6}),${7}
#migrate=False
)
## FIELD
snippet field_
Field('${1:fieldname}', '${2:string}'${3}),${4}
snippet field__
Field(
'${2:fieldname}',
type='${3:string|boolean|integer|double|text|blob|date|time|datetime|upload|password}',
length=${4:None}, required=${5:False}, default=${6:None},
notnull=${7:False}, unique=${8:False},
requires=${9:'<default>'},
label=${10:None}, comment=${11:None}, widget=${12:None},
readable=${13:True}, writable=${14:True},
uploadfolder=${15:None}, autodelete=${16:False}, authorize=${17:None},
ondelete='CASCADE', uploadfield=True, update=None, authorize=None,
autodelte=False, represent=None, compute=None
),${18}
## WIDGETS
snippet widget_
widget=SQLFORM.widgets.${1:string|text|password|integer|double|time|date|datetime|upload|boolean|blob|options|multiple|radio|checkboxes}.widget${2}
# ============================================================================
# Database to HTML
# ============================================================================
snippet sqlform_
SQLFORM(${1:table}, record=${2:None}, deletable=${3:False}${4})${5}
snippet sqlform__
SQLFORM(${1:table}, record=${2:None}, deletable=${3:False}, linkto=${4:None}, upload=${5:None}, fields=${6:None}, labels=${7:None}, col3={}, submit_button='Submit', delete_label='Check to delete:', showid=True, readonly=False, comments=True, keepopts=[], ignore_rw=False, record_id=None, ${8:**attributes})${9}
snippet sqltable_
SQLTABLE(${1:sqlrows}${2})${3}
snippet sqltable__
SQLTABLE(${1:sqlrows}, linkto=${2:None}, upload=${3:None}, orderby=${4:None}, headers={}, truncate=16, columns=None, ${5:**attributes})${6}
# ============================================================================
# Templates
# ============================================================================
snippet include_
{{include '${1:otherview}.html'}}${2}
snippet extend_
{{extend '${1:layout}.html'}}${2}
snippet __
{{=${1:varname}}}${2}
snippet ___
{{${1:code}}}${2}
snippet if_
{{if ${1:expression}:}}${2:code}{{pass}}${3}
snippet if__
{{if ${1:expression}:}}
${2:code}
{{pass}}
snippet else_
{{else:}}
snippet elif_
{{elif ${1:expression}:}}${2}
snippet for_
{{for ${1:item} in ${2:iterable}:}}${3:code}{{pass}}
snippet for__
{{for ${1:item} in ${2:iterable}:}}
${3:code}
{{pass}}
snippet pass_
{{pass}}
snippet block_
{{
${1}
}}
snippet #_
{{# ${1:comment} }}${2}
